#ifndef _NETWORK_H_
#define _NETWORK_H_

#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>


#define PORT 1500

/* Returns true if string represents valid ip adress */
int is_ip_valid(char *);

/* converts given  ip or hostname to sockaddr_in adress */
void url_to_adress(char * url, struct sockaddr_in * adress);

/* connects to given  ip or hostname, returns socket descriptor id */
int socket_open(char * url);

/* open (creates, bind to port, listen) server socket, returns server socket id */
int server_socket_open(short int port);

/* waiting on server socket to accept, returns ne socket_id */
int server_socket_accept(int server_socket_id, struct sockaddr_in * client_adress);

#endif
